fix: replace hardcoded IP with dynamic backend URL in reflection.js#5919
Open
moksha-hub wants to merge 2 commits intosugarlabs:masterfrom
Open
fix: replace hardcoded IP with dynamic backend URL in reflection.js#5919moksha-hub wants to merge 2 commits intosugarlabs:masterfrom
moksha-hub wants to merge 2 commits intosugarlabs:masterfrom
Conversation
The PORT value was hardcoded to a specific AWS IP address (http://3.105.177.138:8000), which causes two problems: 1. Mixed-content security errors on musicblocks.sugarlabs.org (HTTPS page loading HTTP resource) causing the widget to silently fail. 2. Local development requires manually editing the source file every time. This commit replaces the hardcoded value with the same environment- aware dynamic resolver already used in aidebugger.js: - localhost / 127.0.0.1 -> http://localhost:8000 - musicblocks.sugarlabs.org -> https://api.musicblocks.sugarlabs.org - Any other host -> protocol//hostname:8000 Fixes: https://github.com/sugarlabs/musicblocks/issues/TBD
Contributor
|
❌ Some Jest tests failed. Please check the logs and fix the issues before merging. Failed Tests: |
Contributor
|
@moksha-hub the lint check is failing due to formatting issues, and some Jest tests are also failing (reflection.test.js). |
- Reformat reflection.js with Prettier to pass lint CI - Update reflection.test.js PORT expectation: dynamic URL resolver returns 'http://localhost:8000' in jsdom (Jest test environment) instead of the old hardcoded AWS IP
Contributor
|
✅ All Jest tests passed! This PR is ready to merge. |
Contributor
Author
|
@omsuneri @walterbender i identified this issue so created and made a pr please have a review if it helps. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #5918
The
PORTvalue injs/widgets/reflection.jswas hardcoded to a specific AWS IP address (http://3.105.177.138:8000), causing two problems:musicblocks.sugarlabs.orgis served over HTTPS, so loading ahttp://resource from a raw AWS IP is blocked by the browser. The widget silently fails for all production users.Changes Made
Replaced the hardcoded IP in
js/widgets/reflection.js(init()method) with the same dynamic hostname-based resolver thataidebugger.jsalready uses:Testing
localhost: resolves tohttp://localhost:8000✅musicblocks.sugarlabs.org: resolves tohttps://api.musicblocks.sugarlabs.org✅protocol//hostname:8000✅Checklist
aidebugger.jsuses the identical pattern).